/*
* 封装 MONGODB 操作
* 读取mongodb中的DCS数据
*/
const MongoDB = require('../lib/mongo/MongoDb.js');
const ExcelConfig = require('../config/excelConfig.js');

// 通过tag获取
exports.getDcsData = async () => {
    let datalist = [];
    const tagArr = await ExcelConfig.dcs_tags();
    for(let item of tagArr){
        let data = await MongoDB().findOne('history', {
            tag_name: item.tag_name
        }, {}, {
            sort: {
                datetime: -1
            }
        });
        if(data){
            delete data._id;
            delete data.datetime;
            delete data.quality;
            data.address = item.address
            datalist.push(data);
        }
    }

    return datalist;
};
